#ifndef __LM75A_H__
#define __LM75A_H__

#include <stdint.h>
#include "t_i2c_m.h"

#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
    t_i2c_t *i2c;
    uint8_t dev_addr;  // 7位地址
} lm75a_t;

// 初始化
void lm75a_init(lm75a_t *obj, t_i2c_t *i2c, uint8_t addr);

// 读取温度（摄氏度）
int lm75a_read_temp_0P5(lm75a_t *obj, float *out_temp);
int lm75a_read_temp_0P125(lm75a_t *obj, float *out_temp);
// 配置寄存器读写
int lm75a_write_config(lm75a_t *obj, uint8_t config);
int lm75a_read_config(lm75a_t *obj, uint8_t *config);

// 设置高温和低温阈值（摄氏度）
int lm75a_set_thyst(lm75a_t *obj, float temp);
int lm75a_set_tos(lm75a_t *obj, float temp);

// 读取高温和低温阈值
int lm75a_get_thyst(lm75a_t *obj, float *temp);
int lm75a_get_tos(lm75a_t *obj, float *temp);
#ifdef __cplusplus
}
#endif

#endif
